package com.hemi.rhet.util;

import java.util.HashMap;

import org.apache.http.cookie.Cookie;

import android.app.Activity;

import com.hemi.rhet.Constants;

public class ApplicationContext {
	public static final String DOMAIN = Constants.HTTP_PROTOCOL+""+Constants.server_ip+":"+Constants.server_port+"/"+Constants.app_name;
	private static HashMap map = new HashMap();
	public static void setData(String key ,Object value){
		map.put(key, value);
	}
	
	
	public static void clearApplicationData(){
		map.clear();
	}
	
	
	
	public static Object getData(String key ){
		return map.get(key);
	}
	
	
	public static void checkLogin(Activity act){
		if(map.get("userId")==null)
		{
			String uid = AppParam.newInstance(act).get("user.userId");
			map.put("userId", uid);
		}
	}
	public static String  getJsessionidUrl(){
		Cookie sok = (Cookie) map.get(Constants._COOKIE_KEY);
		if(sok==null)
		{
			return "";
		}
		return sok.getName()+"="+sok.getValue();
	}
	
	public static String  getSessionName(){
		Cookie sok = (Cookie) map.get(Constants._COOKIE_KEY);
		if(sok!=null)
		{
		return sok.getName();
		}
		return null;
	}
	public static String  getSessionValue(){
		Cookie sok = (Cookie) map.get(Constants._COOKIE_KEY);
		if(sok!=null)
		{
			return sok.getValue();
			
		}
		return null;
	}
}
